﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExpressionTreeLib
{
    class IndentStringBuilder 
    {
        public static readonly IndentStringBuilder Current = new IndentStringBuilder();

        private int indentLength = 0;

        public void IncreaseIndent(StringBuilder stringBuilder)
        {
            indentLength += 4;
            StartNewLine(stringBuilder);
        }

        public void DecreaseIndent()
        {
            if( indentLength == 0)
                throw new ArgumentOutOfRangeException();

            indentLength -= 4;
        }

        public void StartNewLine(StringBuilder stringBuilder)
        {
            stringBuilder.AppendLine();
            stringBuilder.Append(' ', indentLength);
        }

        public void Reset()
        {
            indentLength = 0;
        }
    }
}
